from sympy import symbols,sqrt,expand,isprime,Function,factor

class Zeta0(object):
    def __init__(self, core):
        abc, becket21, segment10 = self.double_transform(core)
        self.abs =(abc,becket21,segment10)
        x, y, z, t = symbols('x y z t')
        k, m, n = symbols('k m n', integer=True)
        f, g, h = symbols('f g h', cls=Function)
        self.becket21 = becket21
        assert isprime ( abs(becket21[1]))
        f = factor((segment10[0]*y + segment10[1])**2 - (y**3 + self.becket21[0]* y +self.becket21[1] ))
        str0 = str(f)
        s1c = str0.count('(')
        self.is_trans = ')**2' in str0 and s1c == 2
        assert (s1c == 3 or self.is_trans)
        g = -1
        self.core = max(abc)
        if self.core == int(sqrt(self.core))**2:
            not_core = list(abc).copy()
            not_core.remove(self.core)
            assert not_core[0] == - not_core[1]
        self.root = []
        for y1 in abc:
            z1 = abs(segment10[0]*y1 + segment10[1])
            self.root.append((z1,y1))
            g *= (y  - y1)
        self.left = f
        self.right = g

    def test(self):
        assert expand(self.left) == expand (self.right)
        for z1,y1 in self.root:
            assert z1**2 - (y1**3 + self.becket21[0]* y1 +self.becket21[1] )== 0

    def double_transform(self,n):
        x, y, z, t = symbols('x y z t')
        in_sq_n = int(sqrt(n))
        if in_sq_n ** 2 == n:
            return self.double_transform_double(n)
        for i in range(in_sq_n,in_sq_n+3):
            if ( i ** 2 - n) % 2 == 0:
                in_sq_n = i
                number_y = ( i ** 2 - n ) // 2
                break
        for j in range(1,1000):
            z = expand((in_sq_n*y+j)**2 + (y-number_y)*(y-number_y)*(y-n))
            num_prime = z.coeff(y,0)
            if isprime(abs(num_prime)):
                num_complex = z.coeff(y,1)
                break
        return ((number_y,number_y,n),
                (num_complex,num_prime),
                (in_sq_n,j),
                )
 
    def double_transform_double(self,num0):
        x, y, z, t = symbols('x y z t')
        in_sq_n = int(sqrt(num0))
        for k in range(1,100):
            for j in range(1,100):
                z = expand((in_sq_n*y+j)**2 + (y-k)*(y+k)*(y-num0))
                num_prime = z.coeff(y,0)
                if isprime(abs(num_prime)):
                    num_complex = z.coeff(y,1)
                    break
            return ((-k,k,num0),
                    (num_complex,num_prime),
                    (in_sq_n,j),
                    )

from rizefs import zeta_keys
for i in zeta_keys:
    z0 = Zeta0(i)
    k0 = list(set(z0.root))
    if k0[0][1]> k0[1][1]:
        k0 = [k0[1],k0[0]]
    print(k0,',')
